export function useStorage () {
  // 存入
  function setStorage (key: string, val: any) {
    if (!key && !val) return
    localStorage.setItem(key, JSON.stringify(val))
  }

  // 获取
  function getStorage (key: string) {
    if (!key) return
    return JSON.parse(localStorage.getItem(key) as string)
  }

  // 移除单个
  function removeItem (key: string) {
    if (!key) return
    localStorage.removeItem(key)
  }

  // 移除所有
  function removeAll () {
    localStorage.clear()
  }

  return { setStorage, getStorage, removeItem, removeAll }
}
